package riceSystem.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

import riceSystem.dao.DaoTemplateInterface;
import riceSystem.entity.Product;
import riceSystem.exception.RunException;
import riceSystem.service.ServiceTemplateInterface;
@Component("productService")
public class ProductServiceImpl implements ServiceTemplateInterface<Product> {

	private DaoTemplateInterface<Product> productDao;
	
	public DaoTemplateInterface<Product> getProductDao() {
		return productDao;
	}
	@Resource(name="productDao")
	public void setProductDao(DaoTemplateInterface<Product> productDao) {
		this.productDao = productDao;
	}

	public void add(Product t) throws RunException {
		productDao.save(t);
	}

	public void removeById(long id) throws RunException {
		productDao.deleteById(id);
	}

	public void remove(Product t) throws RunException {
		productDao.delete(t);
	}

	public long update(Product t) throws RunException {
		return productDao.update(t);
	}

	public Product getById(long id) throws RunException {
		return productDao.loadById(id);
	}

	public List<Product> getAll() throws RunException {
		return productDao.loadAll();
	}
}
